package com.youhome.business.controller;

import com.youhome.common.exception.CustomException;
import com.youhome.common.response.Result;
import com.youhome.common.response.ResultCode;
import com.youhome.service.response.SchoolAttendanceAreaResult;
import com.youhome.service.service.HomeJunctionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by chen365 on 2018/11/07.
 */
@RestController
@RequestMapping(value = "/school")
@Api(tags = "学区")
public class SchoolController {

    @Autowired
    private HomeJunctionService homeJunctionService;

    @ApiOperation(value = "学校出勤区", notes = "学校出勤区", response = SchoolAttendanceAreaResult.class, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(dataType = "String", name = "houseId", value = "房源ID", required = true, paramType = "path")
    })
    @GetMapping(value = "/attendance-area/{houseId}")
    public Object attendanceArea(@PathVariable String houseId) throws CustomException {
        return new Result<>(ResultCode.SUCCESS, homeJunctionService.selectSchoolAndAttendanceAreaByHouseId(houseId));
    }


}
